{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
{\fonttbl\f0\fnil\fcharset0 Monaco;\f1\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red0\green0\blue191;\red0\green115\blue0;\red191\green0\blue0;
\red56\green156\blue51;\red21\green156\blue5;\red32\green32\blue32;\red96\green96\blue96;}
\deftab560
\pard\pardeftab560\ql\qnatural

\f0\fs18 \cf2 SynthDef\cf0 (\cf3 \\
\fs20 \cf3 EnvelopedSine
\fs18 \cf0 , \{ \cf2 | out, freq = 440, gate = 1,
\fs20 \cf2  a=0.1, d=0.1, s=0.5, r=0.5
\fs18 \cf2  |\cf0  \
		\cf2 var\cf0  z, smooth;\
		smooth = \cf2 LPF\cf0 .kr(MouseX.kr(300,1000),2); \cf4 //portamento\cf0 \
		z = \cf2 EnvGen\cf0 .kr(\cf2 Env\cf0 .adsr, gate) * \cf2 SinOsc\cf0 .ar(smooth, 0, 0.1);\
		\cf2 Out\cf0 .ar(out, z)\
	\}).
\fs20 writeDefFile
\fs18 ("/Users/lodewijk/dev/colours/svn/video-to-sound/");\
(	\
\cf2 SynthDef\cf0 (\cf3 \\clar\cf0 , \{ \cf2 | y = 0.5, size = 0.5, gate = 1, hue 0.3, x=0.4 |\cf0  \
		\cf2 var\cf0  amp, input, ab, ba, bell, p_diff, p_in, pitch, sound, noise_gate, p_m, shape;\
		\
   		\
   		//
\f1\fs20 shape \cf5 =\cf0  Env\cf6 ([\cf0 1\cf5 ,\cf0  0\cf5 ,\cf0  \cf5 -\cf0 0.7\cf5 ,\cf0  0\cf5 ,\cf0  1\cf6 ]\cf5 ,\cf0  \cf6 [\cf0 0.3\cf5 ,\cf0  0.1\cf5 ,\cf0  0.1\cf5 ,\cf0  0.3\cf6 ]\cf5 ,\cf0  \cf6 [\cf0 4\cf5 ,\cf0  \cf5 -\cf0 4\cf5 ,\cf0  4\cf5 ,\cf0  \cf5 -\cf0 4\cf6 ])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable\cf5 ; //super ruig!
\f0\fs18 \cf0 \
   		//shape = 
\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.7\cf5 ,\cf0 0.7\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.05,\cf0 0.45\cf6 ],[0,0,0])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable;
\f0\fs18 \cf0 \
   		\
   		//shape = 
\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.5,1.5,1.5\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.01,0.41,0.09\cf6 ])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable;
\f0\fs18 \cf0 \
   		//shape = 
\f1\fs20 Env\cf6 ([\cf0 0,0,0.6,0.4,0.4\cf6 ]\cf5 ,\cf6 [0.5,0.25,0.01,0.24])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable;
\f0\fs18 \cf0 \
   		shape = 
\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.5,2,2\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.10,0.30,0.10\cf6 ],[5,5,-10,0])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable;
\f0\fs18 \cf0 \
   		\
   		pitch = (round( linlin(y,0,1,60,96) , 1)).midicps;\
		\
		ba = \cf2 DelayC\cf0 .ar(\cf2 InFeedback\cf0 .ar(10, 1), 100.reciprocal , pitch.reciprocal, 1); \cf4 //air that has returned \cf0 \
		\
		//size = linlin(size,0,1,0.15,1);			\
		p_m = ((\cf2 K2A\cf0 .ar(size)) + (size * 0.05 * WhiteNoise.ar))  * \cf2 EnvGen\cf0 .ar(\cf2 Env\cf0 .cutoff(0.2, 1), gate);    \cf4 //env sustains 1, release in 0.2\cf0 \
				\
		p_diff = p_m - ba;\
		\
		p_in = \cf2 Shaper\cf0 .ar(shape.as(LocalBuf),p_diff,p_m);\
		\
		ab = \cf2 DelayC\cf0 .ar(p_in, 100.reciprocal , pitch.reciprocal, 1); \cf4 //air at bell\cf0 \
		\
		bell = \cf2 LPF\cf0 .ar(ab, linlin(hue,0,1,500,3000)); \cf4 //bell reflection\cf0 \
		\
		\cf2 Out\cf0 .ar(10, bell); \cf4 //feedback\cf0 \
		\
		sound = \cf2 HPF\cf0 .ar(bell,500); \
		 \
		\cf2 Out\cf0 .ar(0, \cf2 Pan2\cf0 .ar(sound,linlin(x,0.2,0.8,1,-1),1) ); \cf4 //out\cf0 \
	\
	\}).send(s).writeDefFile("/Users/lodewijk/dev/opencv2/svn/video-to-sound/sc/");\
)\
	\
\pard\pardeftab560\ql\qnatural

\f1\fs20 \cf0 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.3,2,2\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.01,0.39,0.1\cf6 ])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot;\cf0 \
Env\cf6 ([\cf0 0\cf5 ,\cf0  0\cf5 ,\cf0  \cf5 -\cf0 0.7\cf5 ,\cf0  0\cf5 ,\cf0  1\cf6 ]\cf5 ,\cf0  \cf6 [\cf0 0.3\cf5 ,\cf0  0.1\cf5 ,\cf0  0.1\cf5 ,\cf0  0.3\cf6 ])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot\cf5 ;
\f0\fs18 \cf0 	\

\f1\fs20 Env\cf6 ([\cf0 0,0,0.5,0,0\cf6 ]\cf5 ,\cf6 [0.5,0.25,0.01,0.24])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot;
\f0\fs18 \cf0 \

\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.5,2,2\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.10,0.35,0.05\cf6 ],[5,5,-10,0])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot;
\f0\fs18 \cf0 	\

\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,\cf0 0.5,2,2\cf6 ]\cf5 ,\cf6 [\cf0 0.5\cf5 ,0.10,0.30,0.10\cf6 ],[5,5,-10,0])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot;
\f0\fs18 \cf0 	\

\f1\fs20 Env\cf6 ([\cf0 0\cf5 ,0,0.5,0.5,\cf0 0,0,1,1\cf6 ]\cf5 , \cf6 [\cf0 1\cf5 ,0.1,1,0.1,1,0.1,1\cf6 ],[3,3,3,-10,3,3,3,])\cf0 .\cf7 asSignal\cf6 (\cf0 512\cf6 )\cf0 .\cf7 asWavetable.plot;
\f0\fs18 \cf0 \
\
\pard\pardeftab720\ql\qnatural

\f1\fs24 \cf0 SynthDef(\\flute, \{ arg out=0, gate=1, freq=440, amp=1.0, endReflection=0.5, jetReflection=0.5, jetRatio=0.32, noiseGain=0.15, vibFreq=5.925, vibGain=0.0, outputGain=1.0;\
\
	var adsr = (amp*0.2) + EnvGen.ar(Env.adsr(0.005, 0.01, 1.1, 0.01), gate, doneAction: 2);\
	var noise = WhiteNoise.ar(noiseGain);\
	var vibrato = SinOsc.ar(vibFreq, 0, vibGain);\
\
	var delay = (freq*0.66666).reciprocal;\
	var lastOut = LocalIn.ar(1);\
	var breathPressure = adsr*Mix([1.0, noise, vibrato]);\
	var filter = LeakDC.ar(OnePole.ar(lastOut.neg, 0.7));\
	var pressureDiff = breathPressure - (jetReflection*filter);\
	var jetDelay = DelayL.ar(pressureDiff, 0.025, delay*jetRatio);\
	var jet = (jetDelay * (jetDelay.squared - 1.0)).clip2(1.0);\
	var boreDelay = DelayL.ar(jet + (endReflection*filter), 0.05, delay);\
	LocalOut.ar(boreDelay);\
	Out.ar(out, 0.3*boreDelay*outputGain);\
\}.scope);\
\pard\pardeftab560\ql\qnatural

\f0\fs18 \cf0 \
\
\pard\pardeftab720\ql\qnatural

\f1\fs24 \cf0 \{ arg out=0, gate=1, freq=440, amp=1.0, endReflection=0.5, jetReflection=0.5, jetRatio=0.32, noiseGain=0.15, vibFreq=5.925, vibGain=0.0, outputGain=1.0;\
\
	var adsr = (amp*0.2) + EnvGen.ar(Env.adsr(0.005, 0.01, 1.1, 0.01), gate, doneAction: 2);\
	var noise = WhiteNoise.ar(noiseGain);\
	var vibrato = SinOsc.ar(vibFreq, 0, vibGain);\
\
	var delay = (freq*0.66666).reciprocal;\
	var lastOut = LocalIn.ar(1);\
	var breathPressure = adsr*Mix([1.0, noise, vibrato]);\
	var filter = LeakDC.ar(OnePole.ar(lastOut.neg, 0.7));\
	var pressureDiff = breathPressure - (jetReflection*filter);\
	var jetDelay = DelayL.ar(pressureDiff, 0.025, delay*jetRatio);\
	var jet = (jetDelay * (jetDelay.squared - 1.0)).clip2(1.0);\
	var boreDelay = DelayL.ar(jet + (endReflection*filter), 0.05, delay);\
	LocalOut.ar(boreDelay);\
	Out.ar(out, 0.3*boreDelay*outputGain);\
\}.scope\
\
\pard\pardeftab720\ql\qnatural

\f0\fs18 \cf0 \
\pard\pardeftab560\ql\qnatural
\cf0 \
	\
a = \cf2 Synth\cf0 (\cf3 \\clar\cf0 );	\
a.scope;\
a.inspect;\
a.set(\cf3 \\x\cf0 ,0.5);\
a.set(\cf3 \\size\cf0 ,0.4);\
a.set(\cf3 \\hue\cf0 ,0.50);\
a.set(\cf3 \\y\cf0 ,0.5);\
a.set(\cf3 \\gate\cf0 ,0);\
\
\
(\
~window = \cf2 Window\cf0  (\cf8 "Slider"\cf0 );\
4.do\{ \cf2 |i|\cf0  \
	\cf2 var\cf0  slide;\
	slide = \cf2 Slider\cf0 (~window, \cf2 Rect\cf0 (20, 25 * i, 150, 20));\
	slide.action=\{ \cf2 |slider|\cf0 \
		var param;\
		\
		\
		\
		i.switch(\
			0, \{ param = \cf8 "x"\cf0  \},\
			1, \{ param = \cf8 "y"\cf0  \},\
			2, \{ param = \cf8 "size"\cf0  \},\
			3, \{ param = \cf8 "hue"\cf0  \}\
		);\
		\
		param.postln;\
		 \
		s.sendMsg(\cf8 "/n_set"\cf0 ,a.nodeID,param,slider.value);\
		//msg.inspect; \
		//msg.postln;\
	\};\
\};\
~window.front;\
)\
\
\
}